<?php
namespace Admin\Controller;

use Frame\Libs\BaseController;
use Admin\Model\MemberModel;
use Frame\Frame;

final class MemberController extends BaseController{
	public function index(){
		$this->denyAccess();
		//搜索条件
		$where = "2>1";
		if(!empty($_REQUEST["member_search"])) $where .= " AND member_user LIKE '%".$_REQUEST["member_search"]."%'";
		
		//分页参数
		$page = isset($_GET["page"]) ? $_GET["page"] : 1;
		$pageSize = 5;    //每页条数
		$records = MemberModel::getInstance()->rowCount($where);//总记录条数
		$startPage = ($pageSize-1)*$pageSize;//当前页
		$url = [
			"c" => CONTROLLER,
			"a" => ACTION,
		];
		if(!empty($_REQUEST["member_user"])) $url["member_user"] = $_REQUEST["member_user"];
		
		//查询条件
		$data = MemberModel::getInstance()->fetchAll($where);
		
		$data[0]["login_time"] = date("Y-m-d H:i:s",$data[0]["login_time"]);
	
		$pageStr = new \Frame\Vendor\Pager($records, $pageSize, $page, $url);
		$pageStr = $pageStr->showPage();
		$this->smarty->assign([
			"pageStr" => $pageStr,
			"data" => $data
		]);

		$this->smarty->display("Member/index.html");
	}
}